{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
    <div class="think-box-shadow">
        <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">订货号</label>
                <div class="layui-input-inline">
                    <input name="buyCode" value="" placeholder="请输入订货号" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-inline">
                    <input name="name" value="" placeholder="请输入名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">规格型号</label>
                <div class="layui-input-inline">
                    <input name="specs" value="" placeholder="请输入规格型号" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">品牌</label>
                <div class="layui-input-inline">
                    <input name="brand" value="" placeholder="请输入品牌" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">销售合同</label>
                <div class="layui-input-inline">
                    <input name="xsHt" value="" placeholder="请输入销售合同号" class="layui-input">
                </div>
            </div>
<!--            <div class="layui-form-item layui-inline">-->
<!--                <label class="layui-form-label">仓库</label>-->
<!--                <div class="layui-input-inline">-->
<!--                    <input name="warehouseName" value="" placeholder="请输入仓库名称" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="layui-form-item layui-inline">-->
<!--                <label class="layui-form-label">库位</label>-->
<!--                <div class="layui-input-inline">-->
<!--                    <input name="locatorName" value="" placeholder="请输入库位" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item layui-inline">
                <button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="webform"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            </div>
        </form>
        <table class="layui-table margin-top-10" lay-filter="mxTable" lay-skin="line" id="mxTable">
        </table>
        <script type="text/html" id="toolbarDemo">
            <button class="layui-btn layui-btn-sm layui-btn-normal " lay-event="subt" type="button">确认</button>
        </script>
    </div>
{/block}
{block name="script"}
<!-- /主体 -->
<script>
    const moduleInit = ['tool'];
    function gouguInit() {
        var form =layui.form;
        console.log('aaaaaaa')

        var treeTable = layui.table;
        var tableIns = treeTable.render({
            elem: '#mxTable'
            , url: "{:url('')}?punterId={$punterId}&sealContractMxIds={$sealContractMxIds}"
            , method: 'post'
            , toolbar: '#toolbarDemo',
            defaultToolbar: []
            , cellMinWidth: 80
            , cols: [[
                {type: 'checkbox', fixed: 'left'},
                {fixed: 'left', field: 'id', title: 'ID', unresize: true, hide: true}
                // ,{field: 'id', width: 80, title: 'ID号', align: 'center'}
                // , {field: 'bar_code', title: '编码'}
                , {field: 'mdName', title: '名称'}
                , {field: 'brand', title: '品牌'}
                , {field: 'specs', title: '规格型号'}
                , {field: 'unit', title: '单位'}
                , {field: 'buyCode', title: '订货号'}
                , {field: 'xsHt', title: '关联合同'}
                , {field: 'bjNum', title: '合同数量'}
            ]]
            , page: true
        });
        form.on('submit(webform)', function (data) {
            tableIns.reload({
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });
        treeTable.on('toolbar(mxTable)', function (obj) {
            var checkStatus = treeTable.checkStatus(obj.config.id);
            console.log(checkStatus)
            switch (obj.event) {
                case 'add':
                    break;
                case 'subt':
                    var data = checkStatus.data;
                    var ids = []
                    if (data.length) {
                        // data.forEach(function (value, index) {
                        //     ids.push(value)
                        // })
                        saveMx(data)

                    } else {
                        layer.msg('请选择数据');
                    }

                    break;
                case 'import':

                    break;

            }
            ;
        })

    }

    function saveMx(data) {
        parent.saveAddMx(data)

    }
</script>
<!-- 脚本 -->
{/block}


